const Router = require('koa-router');
const { verifyAuth, verifyPermission } = require('../middleware/auth.middleware');
const { create, detail, list, update, remove, fileInfo } = require('../controller/moment.controller');
const { support } = require('../controller/support.controller');

const momentRouter = new Router({
  prefix: "/moment"
});

// 创建一条动态
momentRouter.post("/", verifyAuth, create);
// 根据id获取某条动态
momentRouter.get("/:momentId", detail);
// 获取多条动态
momentRouter.get("/", list);
// 修改一条动态
momentRouter.patch("/:momentId", verifyAuth, verifyPermission, update);
// 删除一条动态
momentRouter.delete("/:momentId", verifyAuth, verifyPermission, remove);
// 动态 点赞/取消点赞
momentRouter.get("/:momentId/support", verifyAuth, support);
// 返回动态配图
momentRouter.get("/images/:filename", fileInfo);

module.exports = momentRouter;
